package com.maila.xiaoaoschool.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.maila.xiaoaoschool.R;
import com.zhy.autolayout.utils.AutoUtils;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 优选商品adapter
 * Created by Administrator on 2017/9/26.
 */

public class DiscountAdapter extends BaseAdapter {
    Context context;

    public DiscountAdapter(Context context) {
        this.context = context;
    }

    @Override
    public int getCount() {
        return 3;
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder = null;
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.item_discount, viewGroup, false);
            holder = new ViewHolder(view);
            view.setTag(holder);
            AutoUtils.autoSize(view);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        if(i==2){
            holder.tvFee.setTextColor(Color.parseColor("#d6d6d6"));
            holder.tvTitle.setTextColor(Color.parseColor("#d6d6d6"));
            holder.tvTiaojian.setTextColor(Color.parseColor("#d6d6d6"));
            holder.tvQuanTitle.setTextColor(Color.parseColor("#d6d6d6"));
            holder.tvTime.setTextColor(Color.parseColor("#d6d6d6"));
            holder.tvTime.setText("已失效");
        }else {
            holder.tvFee.setTextColor(Color.parseColor("#f2673e"));
            holder.tvTitle.setTextColor(Color.parseColor("#f2673e"));
            holder.tvTiaojian.setTextColor(Color.parseColor("#f2673e"));
            holder.tvQuanTitle.setTextColor(Color.parseColor("#333333"));
            holder.tvTime.setTextColor(Color.parseColor("#666666"));
            holder.tvTime.setText("有效期至 2018-09-30");
        }

        return view;
    }


    static class ViewHolder {
        @BindView(R.id.tv_fee)
        TextView tvFee;
        @BindView(R.id.tv_title)
        TextView tvTitle;
        @BindView(R.id.tv_tiaojian)
        TextView tvTiaojian;
        @BindView(R.id.tv_quan_title)
        TextView tvQuanTitle;
        @BindView(R.id.tv_time)
        TextView tvTime;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
